package com.yanqu.road.server.cmd.banquet.cross.goodbanquet;

import com.yanqu.road.pb.banquet.CrossBanquetProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.banquet.CrossBanquetMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

/**
 * @Description
 * @Author cwq
 * @Data 2021/11/9 14:34
 */
@Cmd(code = Protocol.S_GOOD_BANQUET_SYN_FROM_CROSS, desc = "百福宴同步 跨服返回区服 协议")
public class GoodBanquetSynFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        CrossBanquetProto.GoodBanquetSyncMsg crossMsg = CrossBanquetProto.GoodBanquetSyncMsg.parseFrom(packet.getBytes());
        for (long userId : CrossBanquetMgr.getInSystemUserSet()){
            GamePlayer player = GamePlayerMgr.getOnlinePlayer(userId);
            if(player != null){
                player.sendPacket(ClientProtocol.U_CROSS_GOOD_BANQUET_COUNT_SYNC, crossMsg.toBuilder());
            }
        }
    }
}
